﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Extensibility;
using EnvDTE;
using EnvDTE80;

namespace CoNatural.Data.VisualStudio.AddIn.Forms {
	public partial class SelectedItemWizardForm : WizardForm {
		protected Project Project { get; private set; }
		protected string ProjectPath { get; private set; }
		protected ProjectItems RootCollection { get; private set; }
		protected string RootPath { get; private set; }
		protected string RootNamespace { get; private set; }

		public SelectedItemWizardForm() {}

		public SelectedItemWizardForm(SelectedItem selectedItem) {
			if (selectedItem.Project == null) {
				// folder selected
				ProjectItem folder = selectedItem.ProjectItem;
				Project = folder.ContainingProject;
				ProjectPath = Project.Properties.Item("FullPath").Value.ToString();
				RootCollection = folder.ProjectItems;
				RootPath = folder.Properties.Item("FullPath").Value.ToString();
				RootNamespace = Helpers.ProjectItemHelper.GetNamespace(folder, true);
			}
			else {
				// project selected
				Project = selectedItem.Project;
				ProjectPath = RootPath = Project.Properties.Item("FullPath").Value.ToString();
				RootCollection = Project.ProjectItems;
				RootNamespace = Project.Name;
			}
		}
	}
}
